package com.simple.datax.schedule;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
import com.simple.datax.api.MessageService;
import com.simple.datax.flow.util.FailMessageUtil;

/** 
 * @Title: FailMessageScheduleProcessor.java 
 * @Package com.simple.datax.schedule 
 * @Description: TODO(失败报文定时重发器) 
 * @author tonney 
 * @date 2013-1-25 下午02:20:17 
 * @version V1.0 
 */
public class FailMessageScheduleProcessor {
	public Logger log = LoggerFactory.getLogger(this.getClass());
	private MessageService routerMessageService;

	public void setRouterMessageService(MessageService routerMessageService) {
		this.routerMessageService = routerMessageService;
	}

	public void process(){
		String ecxml = "";
		log.debug("schedule begin!");
		try{
			while(true){
				ecxml = FailMessageUtil.getFailMessage();
				if(ecxml!=null){
					routerMessageService.service(ecxml);
				}else{
					return;
				}
			}
		}catch(Exception e){
			FailMessageUtil.addFailMessage(ecxml);
			log.error("ResentScheduleProcessor::process error==>"+e.toString());
			return;
		}
	}
}
